package com.ithjh.config;


import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

public class MybatisConfig {
    @Bean
    public SqlSessionFactoryBean sqlSessionFactoryBean(DataSource dataSource){
        SqlSessionFactoryBean ssfb = new SqlSessionFactoryBean();
        ssfb.setTypeAliasesPackage("com.ithjh");
        ssfb.setDataSource(dataSource);
        return ssfb;
    }

    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer(){
        MapperScannerConfigurer msc = new MapperScannerConfigurer();
        msc.setBasePackage("com.ithjh.dao");
        return msc;
    }
}
//<configuration>

//<typeAliases>
//<package name="com.ithjh.domain"/>
//</typeAliases>

//<environments default="mysql">
//  <environment id="mysql">
//      <transactionManager type="JDBC"/>
//          <dataSource type="POOLED">
//              <property name="driver" value="${jdbc.driver}"/>
//              <property name="url" value="${jdbc.url}"/>
//              <property name="username" value="${jdbc.username}"/>
//              <property name="password" value="${jdbc.password}"/>
//          </dataSource>
//      </environment>
//  </environments>


//<mappers>
//  <package name="com.ithjh.dao"/>
//</mappers>
//</configuration>